<template>
	<view class="fenlei">
		<wuc-tab :tab-list="tabList" :tabCur="TabCur" @change="tabChange" tab-class="text-center text-black bg-white" select-class="text-blue text-xl"></wuc-tab>
	    <swiper :current="TabCur" class="swiper" duration="300" :circular="true" indicator-color="rgba(255,255,255,0)" indicator-active-color="rgba(255,255,255,0)" @change="swiperChange">
			<swiper-item v-for="(item,index) in mainlist" :key="index">
				<view class="big_area">
					<block v-for="(main,index) in item" :key="index">
						<view class="fenleiList clearfix" :id="main.cate_id" @click="toDetail">
							<view class="left">
								<h3>{{main.name}}</h3>
								<text>{{main.book_nums}}本书</text>
								<view class="toMore clearfix" data-id="0">
									<text>查看更多</text>
									<image src="../../static/btn_next_copy7@2x.png" mode=""></image>
								</view>
							</view>
							<view class="right clearfix">
								<image class="big" :src="main.books[0]" mode=""></image>
								<image class="small small_left" :src="main.books[1]" mode=""></image>
								<image class="small small_right" :src="main.books[2]" mode=""></image>
							</view>
						</view>
					</block>
				</view>
			</swiper-item>
	    </swiper>
	</view>
</template>

<script>
	import key from "../../common/key.js" 
	import utils from '../../common/utils.js';
	import WucTab from '@/components/wuc-tab/wuc-tab.vue';
	export default {
		data() {
			return {
				current:0,
				TabCur: 0,
				tabList: [{ name: '男生' }, { name: '女生' }],
				currentIndex: 0,
				active_where: '',
				start: 0,
				TabList:[
				    {title:'男生小说'},
				    {title:'女生小说'}
				],
				nanList: [],
				nvList: [],
				mainlist: []
			}
		},
		computed:{
		    transformX(){
		        let currentTab = this.currentTab;
		        return `translate3d(${currentTab*780}%, 0px, 0px)`
		    },
		    transformXx(){
		        let currentTab = this.currentIndex;
		        return `translate3d(-${currentTab*50}%, 0px, 0px)`
		    }
		},
		components: {
			key,
			utils,
			WucTab
		},
		created() {
			this.aaa();
		},
		methods: {
			tabChange(index) {
				this.TabCur = index;
			},
			swiperChange(e) {
				let { current } = e.target;
				this.TabCur = current;
			},
			aaa(){
				var that = this;
				const data = {
					"app": "YLXS_Android",
					"channel": "H5",
					"device_id": 1054418,
					"t_channel": "YLXS_Android",
					"version": "4.1.0",
				}
				
				let sign = utils.sortObj(data)
				uni.request({
					url: `${key.URL}a2/new/cate/index`,
					method: "POST",
					header: {
						"Content-Type": "application/x-www-form-urlencoded"
					},
					dataType: 'json',
					data: {
						"app": "YLXS_Android",
						"channel": "H5",
						"device_id": 1054418,
						"t_channel": "YLXS_Android",
						"version": "4.1.0",
						"sign": sign,
					},
					success: (res) => {
						console.log(res)
						var bookdata = res.data.data;
						bookdata.nan.forEach((val, index, arr) => {
							var books = val.books;
							books.forEach((v, i, a) => {
								books[i] = utils.imgMd5(v);
							})
						})
						bookdata.nv.forEach((val, index, arr) => {
							var books = val.books;
							books.forEach((v, i, a) => {
								books[i] = utils.imgMd5(v);
							})
						})
						this.nanList = res.data.data.nan
						this.nvList = res.data.data.nv
						// this.nvList = res.data.data.filter(item => item.sex == 2)
						this.mainlist.push(this.nanList, this.nvList)
						console.log(this.mainlist)
					}
				})
			},
			toDetail(e){
				console.log(e)
				var id = e.currentTarget.id;
				console.log(id)
				uni.navigateTo({
					url: '../childPages/fenleiDetail/fenleiDetail/fenleiDetail?id=' + id
				})
			}
		}
	}
</script>

<style scoped>
	.bg-white >>> .wuc-tab-item {
	  color: #818295 !important;
	  font-size: 36upx;
	  margin: 0 80upx;
	  padding-bottom: 12upx;
	  position: relative;
	}
	.bg-white >>> .wuc-tab-item i{
		display: none;
		width: 28upx;
		height: 4upx;
		background: #4F50CE;
		position: absolute;
		bottom: 0;
		left: 50%;
		margin-left: -14upx;
	}
	.bg-white >>> .text-blue{
		color: #4B4C5D !important;
		font-size: 36upx;
	}
	.bg-white >>> .wuc-tab-item.cur i{
	    display: block;
	}
</style>
<style>
	uni-page-body{
		height: 100%;
	}
	.fenlei{
		width: 100%;
		height: 100%;
		padding-top: 30upx;
	}
	.fenlei uni-swiper{
		height: 94%;
		margin-top: 30upx;
	}
	.big_area{
		width: 100%;
		height: 100%;
		overflow: auto;
	}
	.fenleiList{
		width: 690upx;
		height: 230upx;
		margin: 0 auto;
		margin-top: 30upx;
		background:linear-gradient(228deg,rgba(242,244,247,1) 0%,rgba(247,243,242,1) 33%,rgba(242,244,247,1) 100%);
		border-radius:2px;
		overflow: hidden;
	}
	.fenleiList:first-child{
		margin-top: 0;
	}
	.left{
		width: 50%;
		float: left;
	}
	.left h3{
		width:160upx;
		font-size: 40upx;
		font-weight:500;
		color:rgba(75,76,93,1);
		line-height: 56upx;
		margin-left: 40upx;
		margin-top: 30upx;
	}
	.left text{
		width:160upx;
		font-size: 30upx;
		color:rgba(129,130,149,1);
		line-height: 42upx;
		margin-left: 40upx;
		margin-top: 4upx;
	}
	.toMore{
		width: 100%;
		margin-top: 40upx;
	}
	.toMore text{
		width: auto;
		font-size: 26upx;
		color:rgba(179,179,193,1);
		line-height: 36upx;
		float: left;
	}
	.toMore image{
		float: left;
		width: 16upx;
		height: 26upx;
		margin-left: 12upx;
		margin-top: 8upx;
	}
	.right{
		width: 50%;
		height: 100%;
		float: right;
		position: relative;
	}
	.right image{
		display: block;
		position: absolute;
	}
	.right image.big{
		width: 148upx;
		height: 200upx;
		z-index: 2;
		left: 50%;
		margin-left: -74upx;
		bottom: 0;
	}
	.right image.small{
		width: 120upx;
		height: 160upx;
		z-index: 1;
		bottom: 0;
	}
	.right image.small_left{
		left: 50upx;
	}
	.right image.small_right{
		left: auto;
		right: 50upx;
	}
</style>
